<%@page pageEncoding="UTF-8" language="java" %>
<%@ include file="/commons/global.jsp"%>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico" >
<link rel="Shortcut Icon" href="favicon.ico" />
<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/respond.min.js"></script>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/css/style.css" />
<style type="text/css">
	.table-sort tr td{
	    text-align: center;
	}
	.dataTable td.sorting_1{
		background-color: inherit;
	}
	.mt_right {
    width: 100%;
}
</style>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal"  id="trainPlanForm" method="post" action="<%=request.getContextPath()%>/trainPlan/trainPlanUpdate">
		<div class="row cl">
		<input type="hidden" name="trainPlanId" value="${trainPlan.id }"/>
			<label class="form-label col-xs-4 col-sm-2">专业编号：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text"  placeholder="" id="code" name="code" value="${trainPlan.major.code }" readonly>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">专业名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text"  placeholder="" id="name" name="name" value="${trainPlan.major.name }"readonly>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">学制：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select  class="select" id="term" name="term">
					<option value="">---请选择学制---</option>
					<option value="${trainPlan.term }" ${trainPlan.term == 4?'selected="selected"':''}>${trainPlan.term}年</option>
					<option value="${trainPlan.term }" ${trainPlan.term == 5?'selected="selected"':''}>${trainPlan.term}年</option>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">学期：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select  class="select" id="term2" name="term2">
					<option value="">---请选择学期---</option>
					<option value="${trainPlan.term*2 }" ${trainPlan.term == 4?'selected="selected"':''}>${trainPlan.term*2}学期</option>
					<option value="${trainPlan.term*2 }" ${trainPlan.term == 5?'selected="selected"':''}>${trainPlan.term*2}学期</option>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">学分：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text"  placeholder="" id="score1" name="score1" value="${trainPlan.score }" >
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">培养目标：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea cols="" rows="" class="textarea" name="goal"  >${trainPlan.goal }</textarea>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">应获知识与能力：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea cols="" rows="" class="textarea" name="ability"  >${trainPlan.ability }</textarea>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">所学课程：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<c:if test="${trainDetailList == null or trainDetailList.size() == 0 }">
					<textarea cols="" rows="" class="textarea" name="course"  >
						无记录.
					</textarea>
				</c:if>
				<c:if test="${trainDetailList != null and trainDetailList.size() > 0 }">
					<div class="formControls col-xs-8 col-sm-9">
						<textarea cols="" rows="" class="textarea" name="course"  readonly>
							<c:forEach items="${trainDetailList }" var="trainDetail">
								${trainDetail.scheduleVo.course.name}.
							</c:forEach>
						</textarea>
					</div>
				</c:if>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">教学进程：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<table class="table table-border table-bordered table-bg table-hover table-sort" id="schedule">
					<thead>
						<tr class="text-c">
							<th>课程名</th>
							<th>课程编码</th>
							<th>学分</th>
							<th>理论</th>
							<th>实践</th>
							<th>自主</th>
							<th>总计</th>
							<th>考核方式</th>
							<th>第几学期上</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:if test="${trainDetailList == null or trainDetailList.size() == 0 }">
							<tbody>
							<tr  id="add_info">
								<td>
									<input name ="scheduleId" type="hidden" value = " "/>
									<input name="courseName" type="text" placeholder="课程名称"/>
								</td>
								<td>
									<input name="courseCode" type="text" placeholder="课程编号"/>
								</td>
								<td>
									<input id="score" name="score" type="text" placeholder="学分"/>
								</td>
								<td>
									<input id="theory" name="theory" type="text" placeholder="理论"/>
								</td>
								<td>
									<input id="experiment" name="experiment" type="text" placeholder="实践"/>
								</td>
								<td>
									<input id="selfmaster" name="selfmaster" type="text" placeholder="自主"/>
								</td>
								<td>
									<input id="sum" name="sum" type="text" placeholder="总计"/>
								</td>
								<td>
									<input id="examtype" name="examtype" type="text" placeholder="考核方式"/>
								</td>
								<td>
									<input id="termth" name="termth" type="text" placeholder="第几学期上"/>
								</td>
								<td>
									 <a href="javascript:;" onclick='deleteCurrentRow(this);'>删除</a>
								</td>
							</tr>
						</tbody>
						</c:if>
						<div class="cl pd-5 bg-1 bk-gray mt-20">
							<span class="l"> <a href="javascript:;" id="add" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加</a> </span>
						</div>
						<c:if test="${trainDetailList != null and trainDetailList.size() > 0 }">
							<c:forEach items="${trainDetailList }" var="trianDetail">
								<input name ="scheduleId" type="hidden" value = "${trianDetail.scheduleVo.id }"/>
								<tr class="text-c" id="add_info">
								<td>
									<input name="courseName" type="text" placeholder="课程名称" value = "${trianDetail.scheduleVo.course.name }"/>
								</td>
								<td>
									<input name="courseCode" type="text" placeholder="课程编号" value = "${trianDetail.scheduleVo.course.code }"/>
								</td>
								<td>
									<input id="score" name="score" type="text" placeholder="学分" value ="${trianDetail.scheduleVo.score}"/>
								</td>
								<td>
									<input id="theory" name="theory" type="text" placeholder="理论" value ="${trianDetail.scheduleVo.theory}"/>
								</td>
								<td>
									<input id="experiment" name="experiment" type="text" placeholder="实践" value ="${trianDetail.scheduleVo.experiment}"/>
								</td>
								<td>
									<input id="selfmaster" name="selfmaster" type="text" placeholder="自主" value ="${trianDetail.scheduleVo.selfmaster}"/>
								</td>
								<td>
									<input id="sum" name="sum" type="text" placeholder="总计" value ="${trianDetail.scheduleVo.theory+trianDetail.scheduleVo.experiment+trianDetail.scheduleVo.selfmaster}"/>
								</td>
								<td>
									<input id="examtype" name="examtype" type="text" placeholder="考核方式" value ="${trianDetail.scheduleVo.examtype}"/>
								</td>
								<td>
									<input id="termth" name="termth" type="text" placeholder="第几学期上" value ="${trianDetail.scheduleVo.term}"/>
								</td>
								<td>
									 <a href="javascript:;" onclick='deleteCurrentRow(this);'>删除</a>
								</td>
								</tr>
							</c:forEach>
						</c:if>
					</tbody>
				</table>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-4">
				<button id="courseEdit" class="btn btn-primary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<button id="cancel" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</article>

	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/jquery/1.9.1/jquery.min.js"></script> 
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/layer/2.4/layer.js"></script> 
<%-- 	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/icheck/jquery.icheck.min.js"></script>  --%>
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/h-ui/js/H-ui.js"></script> 
	<script type="text/javascript" src="<%=request.getContextPath()%>/static/h-ui.admin/js/H-ui.admin.page.js"></script> 
<script type="text/javascript">
	$("#add").click(function() {
		document.getElementById("schedule").appendChild(document.getElementById("add_info").cloneNode(true));
		});
	function deleteCurrentRow(obj){
	        var tr=obj.parentNode.parentNode;
	        var tbody=tr.parentNode;
			if(tbody.rows.length>1) {
	            tbody.removeChild(tr);
			}
	}

	$(function(){
		$("#cancel").click(function(){
			parent.layer.close(parent.index);
		});
	});
	
	function courseEdit(){
		var data = $("#trainPlanForm").serialize();
		$.ajax({
			url: $("#trainPlanForm").attr("action"),
			data: data,
			type: "post",
			dataType: "json",
			success: function(result){
				if(result.success){
					top.layer.open({
						icon: 1,
						content: '保存成功！',
						time: 1500
					});
					$(window.parent.document).find("#pageForm").submit();
					parent.layer.close(parent.index);
				}else{
					top.layer.open({
						icon: 2,
						content: '保存失败！',
						time: 1500
					});
				}
			}
		});
	}
	$(function(){
		/* 校验 */
		var trainPlanForm ;
		$("#courseEdit").click(function(){
			if(!trainPlanForm.form()){
				return false;
			}else{
				courseEdit();
			}
		});
		trainPlanForm = $("#trainPlanForm").validate({
			"rules":{
				"enterterm":{
					"required":true
				},
				"trainPlanName":{
					"required":true
				},
				"majorName":{
					"required":true
				},
				"majorCode":{
					"required":true
				},
				"term":{
					"required":true
				},
			},
			"messages":{
				"enterterm":{
					"required":"届数不能为空！"
				},
				"trainPlanName":{
					"required":"方案名称不能为空！"
				},
				"majorName":{
					"required":"专业名称不能为空！"
				},
				"majorCode":{
					"required":"专业编号不能为空！"
				},
				"term":{
					"required":"学制不能为空！"
				},
			}
		});
		$("#cancel").click(function(){
			parent.layer.close(parent.index);
		});
		
	});
</script>
</body>
</html>